package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.AdSiteQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.AdvertisementQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.AdvertisementVo;
import cn.ywsj.ywsjmidtier.service.WechatAdvertisementFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName : WechatAdvertisementController
 * @Author : Lenovo
 * @Date: 2021/7/23 10:56
 * @Description :
 */
@RestController
@RequestMapping("/wechat/adver")
public class WechatAdvertisementController {
    @Autowired
    private WechatAdvertisementFeign wechatAdvertisementFeign;
    @GetMapping("/queryadvbyadcode")
    public String queryAdvByAdCode(AdSiteQueryVo adSiteQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(adSiteQueryVo);
        return wechatAdvertisementFeign.queryAdvByAdCode(jsonObject);
    }
    @GetMapping("/shopindex")
    public String queryAdvertisementByAdCodeChange(AdSiteQueryVo adSiteQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(adSiteQueryVo);
        return wechatAdvertisementFeign.queryAdvertisementByAdCodeChange(jsonObject);
    }
    @GetMapping("/getadvertisementlist")
    public String getAdvertisementList(AdvertisementQueryVo advertisementQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(advertisementQueryVo);
        return wechatAdvertisementFeign.getAdvertisementList(jsonObject);
    }
    @PostMapping("/addadvertisement")
    public String addAdvertisement(AdvertisementVo advertisementVo, BindingResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(advertisementVo);
        return wechatAdvertisementFeign.addAdvertisement(jsonObject,result);
    }
    @PostMapping("/modifyadvertisement")
    public String modifyAdvertisement(AdvertisementVo advertisementVo,BindingResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(advertisementVo);
        return wechatAdvertisementFeign.modifyAdvertisement(jsonObject,result);
    }
    @PostMapping("/removeadvertisement")
    public String removeAdvertisement(AdvertisementVo advertisementVo,BindingResult result){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(advertisementVo);
        return wechatAdvertisementFeign.removeAdvertisement(jsonObject,result);
    }
    @PostMapping("/productclassadsitelist")
    public String ajaxProductClassAdsiteList(Long classId){
      return wechatAdvertisementFeign.ajaxProductClassAdsiteList(classId);
    }
    @GetMapping("/getlogolanguage")
    public String getLogoLanguage(){
      return wechatAdvertisementFeign.getLogoLanguage();
    }
}
